package server;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.logging.Logger;

import sheduler.EmailTask;
import smtp.SmtpSender;

public class StopServlet implements Servable {
	private Server server;
	
	public StopServlet(Server s) {		
		this.server = s;
	}

	@Override
	public void serve(Request request, Response response) {
		OutputStream output = response.getBodyStream();
		try {		
			output.write("<h1>Server stopped</h1>\n".getBytes());
			server.shutDown();
		} catch (IOException e) {
			Logger.getLogger(Server.LOG).severe("Cannot serve Servlet");
		}		
	}

	@Override
	public String getContentType() {
		return "text/html";
	}

}
